package com.admin.dbdao;

import com.admin.bean.KeyWord;
import com.data.dbdao.BaseDao;
import org.springframework.stereotype.Repository;

import javax.transaction.Transactional;
import java.util.List;

/**
 * 关键词管理
 *
 * @author:HingLo
 * @create 2017-09-11 16:53
 **/
@Repository
@Transactional
public class KeywordDao extends BaseDao {

    public List<KeyWord> findAllKeywordDao() {
        String hql = "select KeyWord.id as id,KeyWord.name as name,KeyWord.contents as contents,KeyWord.ctime as ctime,KeywordType.name as type from KeyWord as KeyWord,KeywordType as KeywordType where KeyWord.type=KeywordType.id";
        return (List<KeyWord>) super.findMassageDao(hql);
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    public boolean delKeywordDao(String id) {
        String hql = "delete from KeyWord where id=?";
        return super.updateManyMssageDao(hql, id) > 0;
    }

    /**
     * 添加
     *
     * @param keyWord
     * @return
     */
    public boolean submitkeywordDao(KeyWord keyWord) {
        return super.saveMassageDao(keyWord);
    }
}
